/*
 ============================================================================
 Page	     : 342-343
 Name        : test_fit.c
 Date	     : 20210406
 Author      : Hbue 18060333
 Copyright   : Your copyright notice
 Description : 使用缩短字符串长度的函数
 ============================================================================
 */

#include <stdio.h>
#include <string.h>		/* 内含字符串函数原型 */
void fit(char *, unsigned int);

int main(void)
{
	char message[] = "Things should be as simple as possible," " but not simpler.";

	puts(message);
	fit(message, 38);
	puts(message);
	puts("Let's look at some more of the string.");
	puts(message + 39);

	return 0;
}

void fit(char *string, unsigned int size)
{
	if(strlen(string) > size)
	{
		string[size] = '\0';
	}
}

